package com.ad.pet.app.main.view;

import android.app.Dialog;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.ad.pet.R;
import com.ad.pet.app.main.adapter.Time2TipsVpAdapter;
import com.ad.pet.utils.LyxUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by liuyixiang on 2019/9/11.
 */

public class Look2TimesTipsDialog extends Dialog {
    String mPrice;
    public Look2TimesTipsDialog(Context context, String price) {
        super(context, R.style.custom_dialog2);
        mPrice = price;
        initView(context);
    }

    private void initView(Context context
    ){
        View view = View.inflate(context, R.layout.dialog_tips_how_2_seconds,null);
        ViewPager myViewPager = view.findViewById(R.id.vp_view);

        View view1 = View.inflate(context, R.layout.fragment_chose_first_step,null);
        view1.findViewById(R.id.linear_1).setVisibility(View.VISIBLE);
        ((TextView) view1.findViewById(R.id.tv_tips_2_agen_price)).setText(mPrice+"元");
        view1.findViewById(R.id.linear_2).setVisibility(View.GONE);
        view1.findViewById(R.id.linear_3).setVisibility(View.GONE);
        View view2 = View.inflate(context, R.layout.fragment_chose_first_step,null);
        view2.findViewById(R.id.linear_1).setVisibility(View.GONE);
        view2.findViewById(R.id.linear_2).setVisibility(View.VISIBLE);
        view2.findViewById(R.id.linear_3).setVisibility(View.GONE);
        ((TextView) view2.findViewById(R.id.tv_tips_2_agen_price)).setText(mPrice+"元");
        View view3 = View.inflate(context, R.layout.fragment_chose_first_step,null);
        ((TextView)view3.findViewById(R.id.tv_money)).setText(mPrice+"元");
        view3.findViewById(R.id.linear_1).setVisibility(View.GONE);
        view3.findViewById(R.id.linear_2).setVisibility(View.GONE);
        ((TextView) view3.findViewById(R.id.tv_tips_2_agen_price)).setText(mPrice+"元");
        view3.findViewById(R.id.linear_3).setVisibility(View.VISIBLE);
        view3.findViewById(R.id.tv_continue).setVisibility(View.GONE);
        view3.findViewById(R.id.btn_konw).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        List<View> views = new ArrayList<>();
        views.add(view1);
        views.add(view2);
        views.add(view3);
        myViewPager.setAdapter(new Time2TipsVpAdapter(views));

        view1.findViewById(R.id.iv_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        view2.findViewById(R.id.iv_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });view3.findViewById(R.id.iv_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

//        ImageView imageView = view.findViewById(R.id.iv_bg);
//        if ("cn".equals(SpUtil.getInstance().getString(Constant.LANGUAGE, "cn"))){
//            imageView.setImageResource(R.drawable.ic_reg_succ_en);
//        }else {
//            imageView.setImageResource(R.drawable.ic_regist_succ);
//        }

        setContentView(view);



        Window window = this.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = LyxUtils.dp2px(context,250);
        lp.height = LyxUtils.dp2px(context,300);
        this.getWindow().setAttributes(lp);
        window.setGravity(Gravity.CENTER);
    }
}
